package singleton;

/**
 * 枚举饿汉式,只要类初始化该枚举对象就已被创建，提前创建
 */
public enum Singleton2{
    INSTANCE;

    //枚举类的构造方法默认修饰符就是private
    Singleton2(){
        System.out.println("private Singleton2");
    }

    @Override
    public String toString() {
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
    }

    public static Singleton2 getInstance(){return INSTANCE;}

}
